import {Component, OnInit} from '@angular/core';
import {HeroServiceService} from './service/hero-service.service';
import {HEROES} from './service/mock-heroes';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {


  constructor(private heroService: HeroServiceService) {
  }

  title = 'this is a dog';
  selectedHero: Hero;
  // heros: Hero[];
  hero: Hero = {
    id: 1,
    name: 'dog'
  };
   heroes: Hero[];

  ngOnInit(): void {
    // Promise
    this.heroService.getHeroes().then(heroes => this.heroes = heroes);
  }

  showDetail(h: Hero): void {
    this.selectedHero = h;

  }
}


export class Hero {
  id: number;
  name: string;
}


